﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;

namespace Twi.COMMON.WPF
{
    public partial class DataGrid1
    {
        public void TreeExpander_Click(object sender, RoutedEventArgs e)
        {            
            CheckBox chk = sender as CheckBox;
            CustomDataGrid dg = chk.Tag as CustomDataGrid;
            if (!dg.TreeNodeExpandable)
                return;
            RowXElement rd = chk.DataContext as RowXElement;
            if (rd == null)
                return;
            if (chk.IsChecked == true)
            {
                rd.IsExpanded = true;
            }
            else
            {
                rd.IsExpanded = false;
            }
            dg.CommitEdit(DataGridEditingUnit.Row, true);
            dg.Items.Refresh();
        }

    }
}
